package com.ewanghuiju.app.ui.my.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ewanghuiju.app.R;
import com.ewanghuiju.app.model.bean.local.WalletClassifyBean;

import androidx.core.content.ContextCompat;

/**
 * @author sj  qq:751943509
 * @class 流式布局  钱包分类
 * @time 2020/2/20
 */
public class WalletClassifyFlexboxAdapter extends BaseQuickAdapter<WalletClassifyBean, BaseViewHolder> {


    public WalletClassifyFlexboxAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    protected void convert(BaseViewHolder helper, WalletClassifyBean item) {

        TextView tvFlexbox = helper.getView(R.id.tv_flexbox_item);
//        if (mType == 1) {
        if (TextUtils.isEmpty(item.getName())) {
            tvFlexbox.setVisibility(View.GONE);
        } else {
            tvFlexbox.setVisibility(View.VISIBLE);
            tvFlexbox.setText(item.getName());
        }
//        } else {
//            if (TextUtils.isEmpty(item.getValue())) {
//                tvFlexbox.setVisibility(View.GONE);
//            } else {
//                tvFlexbox.setVisibility(View.VISIBLE);
//                tvFlexbox.setText(item.getValue());
//            }
//        }
        if (item.isSelected()) {
            tvFlexbox.setBackgroundResource(R.drawable.corner_flowlayout_selected_50);
            tvFlexbox.setTextColor(ContextCompat.getColor(mContext, R.color.colorPrimary));
        } else {
            tvFlexbox.setBackgroundResource(R.drawable.corner_f2f2f2_50);
            tvFlexbox.setTextColor(ContextCompat.getColor(mContext, R.color.color_333));
        }
        tvFlexbox.setSelected(item.isSelected());
    }
}
